package com.lwq.seata.controller;

import com.lwq.seata.entity.TAmount;
import com.lwq.seata.entity.TOrder;
import com.lwq.seata.feign.TestFeignClient;
import com.lwq.seata.service.ITOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("order-service")
@Slf4j
public class TestController {

    @Autowired
    private ITOrderService orderService;

    @Autowired
    private TestFeignClient testFeignClient;


    @GetMapping("sayHello")
    public String sayHello(){
        return "hello";
    }


    @GetMapping("testFeignSayHello")
    public String testFeignSayHello(){
        log.info("testFeignSayHello call sayHello");
        return testFeignClient.sayHello();
    }


    @PostMapping("crateOrder")
    public String crateOrder(@RequestBody TOrder tOrder){
        orderService.crateOrder(tOrder);
        return "success";
    }
}
